﻿using CDMS.BLL;
using DevExpress.XtraTreeList;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CDMS.Utilities
{
    public static class TreeListDataSource
    {
        public static void CustomerGroup(TreeList treeList1)
        {
            treeList1.OptionsSelection.InvertSelection = true;
         
            // Look and feel
            treeList1.LookAndFeel.UseDefaultLookAndFeel = false;
            treeList1.LookAndFeel.SkinName = "iMaginary";

            treeList1.OptionsBehavior.Editable = false;
            //treeList1.OptionsView.ShowColumns = true;
            treeList1.OptionsView.ShowIndicator = false;
            treeList1.OptionsView.ShowHorzLines = false;
            treeList1.OptionsView.ShowVertLines = false;
            //treeList1.OptionsView.ShowRoot = false;

            DataTable dt = new DataTable();
            Category_BLL category_BLL = new Category_BLL(Entities.EnumCategory.CustomerGroup);
            dt = category_BLL.GetALLActivated();
            DataRow dr = dt.NewRow();
            dr["CustomerGroup_ID"] = 0;
            dr["CustomerGroup_Name"] = "Tất cả";
            dt.Rows.InsertAt(dr, 0);

            treeList1.DataSource = dt;
            treeList1.KeyFieldName = "CustomerGroup_ID";
            treeList1.ParentFieldName = "CustomerGroup_ID";
            treeList1.OptionsBehavior.PopulateServiceColumns = true;
            treeList1.PopulateColumns();
            treeList1.BestFitColumns();
            treeList1.ExpandAll();

            treeList1.Columns["CustomerGroup_ID"].Visible = false;
            treeList1.Columns["CustomerGroup_Activated"].Visible = false;
            treeList1.Columns["CustomerGroup_Note"].Visible = false;
        }
    }
}
